package com.gaswell.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.gaswell.common.log.LogAnnotation;
import com.gaswell.pojo.JhRtuConfig;
import com.gaswell.service.JhRtuConfigService;
import com.gaswell.service.ModbusSiteService;
import com.gaswell.vo.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("modbussite")
@Api(tags = "组态图参数控制")
public class ModbusSiteController {
    @Autowired
    private ModbusSiteService modbusSiteService;
    @Autowired
    private JhRtuConfigService jhRtuConfigService;

    @ApiOperation("查询所有数据")
    @PostMapping("/all")
    @LogAnnotation(module = "MODBUS日志", operator = "查询所有数据")
    public Result selectAll(String userName) {
        return modbusSiteService.selectAll();
    }

    @ApiOperation("查询所有数据  根据井号查询")
    @PostMapping("/selectAllByJh")
    @LogAnnotation(module = "MODBUS日志", operator = "查询所有数据  根据井号查询")
    public Result selectAllByJh(String userName, String jh) {
        QueryWrapper<JhRtuConfig> jhRtuConfigQueryWrapper = new QueryWrapper<>();
        jhRtuConfigQueryWrapper.eq("jh", jh);
        List<JhRtuConfig> list = jhRtuConfigService.list(jhRtuConfigQueryWrapper);
        return Result.success(list);
    }


}
